package com.ltmonitor.web.mq;

import com.ltmonitor.service.IJT808MessaagePushService;
import com.ltmonitor.vo.JT808MessageVo;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;


public class JT808MessageListener implements MessageListener {
	private static Logger logger = Logger.getLogger(JT808MessageListener.class);

	@Autowired
	private IJT808MessaagePushService jt808MessaagePushService;

	// 当收到消息后，自动调用该方法
	@Override
	public void onMessage(Message message) {

		ObjectMessage tm = (ObjectMessage) message;
		try {
			//logger.error("QueueMessageListener监听到消息：\t" + tm.getObject());
			jt808MessaagePushService.pushMessage((JT808MessageVo) tm.getObject());
		} catch (Exception e) {
			logger.error(e.getMessage(),e);
		}
	}

}
